# -*- coding:utf8 -*-
import datetime

from django.db import models

from wanpuzzle.models import base

__author__ = 'Forcs'


class Program(base.BaseModel):

    url = models.CharField(max_length=200, null=False, default='')  # 视频地址
    timestamp = models.BigIntegerField(null=False, default=0)  # 视频源时间戳
    category = models.PositiveSmallIntegerField(null=False, default=0)  # 栏目
    token = models.CharField(max_length=32, null=False, default='', unique=True)  # 视频唯一标识
    is_trailder = models.BooleanField(null=False, default=False)  # 是否是trailer


class Wangwangshow(base.BaseModel):

    stb_user_id = models.CharField(max_length=32, null=False, default='')  # 机顶盒用户id
    wx_user_id = models.CharField(max_length=32, null=False, default='')  # 微信用户id号
    wx_nickname = models.CharField(max_length=32, null=False, default='unknown')  # 微信用户昵称
    portrait_url = models.URLField(null=False, default='')  # 头像地址
    video_url = models.URLField(null=False, default='')  # 视频地址
    cover_url = models.URLField(null=False, default='')  # 封面地址
    date_added = models.DateTimeField(null=True)  # 添加时间
    token = models.CharField(max_length=32, null=False, default='', unique=True)  # 资源唯一标记，一串32位的密串
    like_count = models.PositiveIntegerField(null=False, default=0)  # 点赞次数
    visited_count = models.PositiveIntegerField(null=False, default=0)  # 播放次数
    title = models.CharField(max_length=30, null=True, default='')  # 汪汪show标题
    is_recommend = models.BooleanField(null=False, default=False)  # 是否上推荐位

    def update_like(self, count):
        """
        更新点赞数
        :param count:
        :return:
        """
        self.like_count += count
        self.save()
        return self.like_count


class TimeProgram(base.BaseModel):

    url = models.CharField(max_length=200, null=False, default='')  # 视频地址
    timestamp = models.BigIntegerField(null=False, default=0)  # 视频源时间戳
    token = models.CharField(max_length=32, null=False, default='', unique=True)  # 视频唯一标识
    time_start = models.DateTimeField(null=True)  # 视频起始时间
    time_end = models.DateTimeField(null=True)  # 视频结束时间


class WikiDetails(base.BaseModel):

    token = models.CharField(max_length=32, null=False, default='')  # wiki内容标识
    content = models.TextField(null=True)  # wiki内容
    content_index = models.IntegerField(null=False, default=0)  # 内容索引
    image_url = models.URLField(null=True)  # 图片地址


class WikiList(base.BaseModel):

    token = models.CharField(max_length=32, null=False, default='', unique=True)  # wiki内容token
    cover_url = models.URLField(null=True)  # 封面地址
    title = models.CharField(max_length=30, null=False, default='')  # 标题
    visited_count = models.IntegerField(null=False, default=0)  # 浏览次数
    timestamp = models.BigIntegerField(null=False, default=0)  # 添加的时间戳
    is_recommend = models.BooleanField(null=False, default=False)  # 是否上推荐位


class HotRecommend(base.BaseModel):

    token = models.CharField(max_length=32, null=False, default='')  # 热点推荐内容token
    content_type = models.IntegerField(null=False, default=0)  # 内容类型
    cover_url = models.TextField(null=True)  # 封面地址
    title = models.CharField(max_length=30, null=False, default='')  # 标题
    visited_count = models.IntegerField(null=False, default=0)  # 浏览次数
    timestamp = models.BigIntegerField(null=False, default=0)  # 添加的时间戳
    is_invalid = models.BooleanField(null=False, default=False)  # 是否删除


class Dogtv(base.BaseModel):
    
    cover_name = models.CharField(max_length=40, null=False, default='')  # 封面图片
    position = models.IntegerField(null=False, default=0)  # 位置